package leetcode.toend;

public class T1221 {
    class Solution {
        public int balancedStringSplit(String s) {
            int l=0,r=0,res=0;
            char[] chars = s.toCharArray();
            for (char c : chars) {
                if (c=='L')l++;
                if (c=='R')r++;
                if (l==r)res++;
            }
            return res;
        }
    }
}
